import os
import sys
print(os.getcwd())
from server.kb_api import _create_kb, _delete_kb, _update_kb, _show_kbs
from server.kb_api import create_kb, delete_kb, update_kb, show_kbs
from server.chat_api import _chat_with_openai_lc, _chat_with_openai_rq
from server.chat_api import chat_with_openai_lc, chat_with_openai_rq

from fastapi import FastAPI
from server.utils import APIResponse, MakeFastAPIOffline,LLMResponse
import uvicorn




def create_app():
    app = FastAPI(title='API Server')
    app.post("/chat/chat",
             tags=["chat"],
             response_model=LLMResponse,
             summary="与openai对话")(chat_with_openai_rq)
    app.post("/chat/chatlc",
             tags=["chat"],
             response_model=LLMResponse,
             summary="与openai对话")(chat_with_openai_lc)

    app.post("/kb/create_kb",
             tags=["kb_operation"],
             response_model=APIResponse,
             summary="创建知识库")(create_kb)
    app.post("/kb/delete_kb",
             tags=["kb_operation"],
             response_model=APIResponse,
             summary="删除知识库")(delete_kb)
    app.post("kb/update_kb",
             tags=["kb_operation"],
             response_model=APIResponse,
             summary="更新知识库")(update_kb)
    app.get("/kb/show_kbs",
            tags=["kb_operation"],
            response_model=APIResponse,
            summary="展示知识库列表")(show_kbs)
    return app

if __name__ == '__main__':
    app = create_app()
    MakeFastAPIOffline(app)
    uvicorn.run(app,
                host='0.0.0.0',
                port=8003)
